
$(document).ready(function() {
	$.ajax({
		type: "post",
		url: "myUser",
		async: true,
		dataType: 'json',
		success: function(data) {
			console.log(data)
			var resultJson = data.resultJson;
			if(resultJson == '1'){
				var name= data.userVo.name;//名字
				var location= data.userVo.location;//地址
				var phoneNum= data.userVo.phoneNum;//联系电话
				var synopsis= data.userVo.synopsis;//个人简介/个性签名
				var sex= data.userVo.sex;//性别
				var face=data.userVo.myFile.name;//头像文件名
				var servicePath='myAssets//img//face//';//
				 $("#name").val(name);  
				 $("#location").val(location);  
				 $("#phoneNum").val(phoneNum);  
				 $("#synopsis").val(synopsis);  
				 console.log(face)
				  console.log(servicePath)
				 if(sex == 'male'){//男
					 $("#sex-id").html('<label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="male" data-am-ucheck checked> 男</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="girl" data-am-ucheck> 女</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="secret" data-am-ucheck> 保密</label>');
				 }
				 if(sex == 'girl'){//女
					 $("#sex-id").html('<label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="male" data-am-ucheck > 男</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="girl" data-am-ucheck checked> 女</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="secret" data-am-ucheck> 保密</label>');
						
				 }
				 if(sex == 'secret'){//保密
					 $("#sex-id").html('<label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="male" data-am-ucheck> 男</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="girl" data-am-ucheck> 女</label><label class="am-radio-inline"><input type="radio" id="sex" name="sex" value="secret" data-am-ucheck checked> 保密</label>');
						
				 }
				 	$('#faceimg').attr('src',servicePath+face);
			}else{
				window.location.href = 'myuserVo.action';
			}	
		},
		error: function() {}
	});
})

$('#btn').click(function(){		
	$.ajax({
		//几个参数需要注意一下
	    type: "POST",//方法类型
	    async: true,
	    url: "myUserUpdate" ,//url
	    data: $('#form-user').serialize(),// 序列化表单值   
        success: function(data) {  
        	var resultJson = data.resultJson;
            if(resultJson=='1'){
            	window.location.href = 'myUser';
            }else{
            	window.location.href = 'myUserUpdate';
            }        
        },
    error: function() {  }    
	})
})
